<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <script type="text/javascript">
        // 利用原型，可以提取共有属性
        Car.prototype.height = 1400;
        Car.prototype.lang = 4900;
        Car.prototype.carName = 'BMW';
        function Car(color, owner) {
            this.owner = owner;
            this.color = color;
            // this.height = 1400;
            // this.lang = 4900;
            // this.carName = 'BMW';
        }
    
        var car = new Car('red', 'prof.bai');
        var car1 = new Car('green', 'prof.zhang');
        console.log(car.carName);
        console.log(car1.carName);
    </script> -->

    <!-- <script>

        Person.prototype.lastName = 'Deng';
        function Person(name) {
            this.name = name;
        }
        var person = new Person('xuming');

        person.lastName = 'james';
        // 改变构建的person对象，原型并没有被改变，给自己增加了lastName属性
        // 当自己没有相应属性时，会去原型上面找

        // 查

        console.log(Person.prototype.lastName);



        // 增
        Person.prototype.address = '小西丈';
        person.__proto__.a = 'dongzhang'

        // 改
        Person.prototype.lastName = 'James';
        console.log(person.__proto__.lastName);
        delete person.lastName; 
        delete person.abc;  // 返回true，自身本来就没有
        // 删除的是自己的属性
    </script> -->

    <script>
        //一种简化的写法,但是会丢失原型上面的 constructor 属性
        Car.prototype = {
            height: 1400,
            lang: 4900,
            carName: 'BMW'
        }

        function Car() {

        }

        var car = new Car();


    </script>
</body>
</html>